<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<div class="line-big">
	<div class="xl12">
		<div class="panel border-back">
			<div class="panel-body">
				<div class="line-big">
					<div class="xl5 text-left">
						<c:if test="${param.buyerId!=null&&param.buyerId!='' }">
							<button id="add_buyer_special_commission_button" class="button border-blue " data-id="${param.buyerId }">
								<span class="icon-plus-circle"></span> 添加此用户特殊佣金
							</button>
						</c:if>
						<c:if test="${param.goodsId!=null&&param.goodsId!='' }">
							<button id="add_goods_special_commission_button" class="button border-blue " data-id="${param.goodsId }">
								<span class="icon-plus-circle"></span> 添加此商品特殊佣金
							</button>
						</c:if>
						<button id="import_buyer_goods_special_commission_button" class="button bg-blue" data-id="${param.goodsId }">
							<span class="icon-upload"></span> 批量导入用户商品特殊佣金
						</button>
					</div>
					<div class="xl2 text-right">
						<%-- <div class="field field-icon-right" title="查找文章">
							<span class="icon icon-search" id="search_article_button"></span>
							<input type="text" class="input radius-rounded" id="keyword_of_article_input" value="${param.k }" placeholder="文章id,文章标题,文章导读" />
						</div> --%>
					</div>
					<div class="xl5 text-left"></div>
				</div>

			</div>
			<div class="panel-foot bg-yellow-light border-back">
				<div class="line-big">
					<div class="xl4 text-center border-small border-right border-blue">买家信息</div>
					<div class="xl4 text-center border-small border-right border-blue">商品信息</div>
					<div class="xl1 text-center border-small border-right border-blue">佣金(元)</div>
					<div class="xl1 text-center border-small border-right border-blue">更新时间</div>
					<div class="xl2 text-center">操作</div>
				</div>
			</div>
			<ul class="list-group list-striped">
				<c:forEach items="${goodsCommissionViewList}" var="gcv">
					<li id="li_${gcv.goodsCommission.goodsCommissionId }">
						<div class="line-big">
							<div class="xl4 text-left">
								<h5 class="text-left">
									<strong> ${gcv.buyer.buyerNickname } </strong>
									<c:if test="${gcv.buyer.buyerName!=null&&gcv.buyer.buyerName!='' }">
									(${gcv.buyer.buyerName })
									</c:if>
								</h5>
								<h6 class="text-left G-MarginTop5">
									<c:if test="${gcv.buyer.buyerCountry!=null&&gcv.buyer.buyerCountry!='' }">
									${gcv.buyer.buyerCountry }
									</c:if>
									<c:if test="${gcv.buyer.buyerProvince!=null&&gcv.buyer.buyerProvince!='' }">
									${gcv.buyer.buyerProvince }
									</c:if>
									<c:if test="${gcv.buyer.buyerCity!=null&&gcv.buyer.buyerCity!='' }">
									${gcv.buyer.buyerCity }
									</c:if>
								</h6>
								<c:if test="${gcv.buyer.buyerSex!=null&&gcv.buyer.buyerSex!='' }">
									<h6 class="text-left G-MarginTop5">${gcv.buyer.buyerSex=='1'?'男':'女' }</h6>
								</c:if>
								<h6 class="text-left G-MarginTop5">用户编号：${gcv.buyer.buyerId }</h6>
							</div>
							<div class="xl4 text-left">
								<h5 class="text-left">
									<strong> ${gcv.goods.goodsName } </strong>
								</h5>
								<h6 class="text-left G-MarginTop5">商品编号：${gcv.goods.goodsId }</h6>
							</div>
							<div class="xl1 text-center">
								<fmt:formatNumber value="${gcv.goodsCommission.goodsCommission }" type="currency" pattern="#,##0.##" />
							</div>
							<div class="xl1 text-center">
								<h6>
									<fmt:formatDate value="${gcv.goodsCommission.commissionUpdateTime}" pattern="yyyy-MM-dd HH:mm:ss" />
								</h6>
							</div>
							<div class="xl2 text-center">
								<button class="special_commission_need_update_button button button-little bg-blue" data-id="${gcv.goodsCommission.goodsCommissionId }">
									<span class="icon-pencil"></span> 修改
								</button>
								<button class="special_commission_need_delete_button button button-little bg-red" data-id="${gcv.goodsCommission.goodsCommissionId }" data-li="#li_${gcv.goodsCommission.goodsCommissionId }">
									<span class="icon-trash-o"></span> 删除
								</button>
							</div>
						</div>
					</li>
				</c:forEach>
			</ul>
			<div class="panel-foot bg-white border-back" id="special_commission_list_pages" data-url="pages_button" data-index="${page.currentIndex}" data-pages="${page.totalPages}"
				data-href="shop/show_special_commission_info_list?buyerId=${param.buyerId }&goodsId=${param.goodsId }&i="></div>
		</div>
	</div>
</div>
<div class="clearfix G-MarginTop100"></div>
<div style="display: none;" id="k" data-value="${param.k }"></div>
<div id="see_article_detail"></div>
<script type="text/javascript" src="js/pintuer.js"></script>
<script type="text/javascript">
	$(function()
	{

		//添加佣金
		$("#add_buyer_special_commission_button").click(function()
		{
			$("#admin_div").load("shop/ajax/buyer/add_commission_info.jsp?buyerId=" + $(this).attr("data-id"), {}, function()
			{

			});
		});
		//添加佣金
		$("#add_goods_special_commission_button").click(function()
		{
			$("#admin_div").load("shop/ajax/buyer/add_commission_info.jsp?goodsId=" + $(this).attr("data-id"), {}, function()
			{

			});
		});
		//批量导入用户商品特殊佣金
		$("#import_buyer_goods_special_commission_button").click(function()
		{
			$("#admin_div").load("shop/ajax/buyer/import_commission_info.jsp", {}, function()
			{

			});
		});

		//更新佣金
		$(".special_commission_need_update_button").click(function()
		{
			$("#admin_div").load("shop/shop_update_special_commission?buyerId=${param.buyerId }&goodsId=${param.goodsId }&id=" + $(this).attr("data-id"), {}, function()
			{

			});
		});

		//删除特殊佣金
		$(".special_commission_need_delete_button").each(function()
		{
			$(this).click(function()
			{
				if (confirm("确认删除此用户对此商品的特殊佣金吗?") == false)
				{
					return false;
				}
				var ids = "";
				ids = $(this).attr("data-id");
				var obj = $(this);

				obj.attr("disabled", "disabled");
				$.post("admin/m_delete_special_commission_do",
				{
					"commonStr" : ids
				}, function(json)
				{
					if (json.success == false)
					{
						alert(json.info);
						obj.removeAttr("disabled");
					}
					else
					{
						obj.removeAttr("disabled");
						$(obj.attr("data-li")).remove();
					}
				},
				//返回类型
				"json");
			});
		});

		$("#special_commission_list_pages").load($("#special_commission_list_pages").attr("data-url"),
		{
			"page.currentIndex" : $("#special_commission_list_pages").attr("data-index"),
			"page.totalPages" : $("#special_commission_list_pages").attr("data-pages"),
			"page.href" : $("#special_commission_list_pages").attr("data-href")
		}, function()
		{
		});
		$("#special_commission_list_pages").on("click", "button[data-url]", function()
		{
			$("#admin_div").load(encodeURI($(this).attr("data-url")), {}, function()
			{
			});
		});

		$("#search_article_button").click(function()
		{
			var keyword = $("#keyword_of_article_input").val();
			if (keyword.length <= 0)
			{
				return false;
			}
			$("#admin_div").load(encodeURI("shop/show_article_info_list?k=" + keyword), {}, function()
			{
			});
		});
		$("#keyword_of_article_input").keydown(function(event)
		{
			if (event.keyCode == 13)
			{
				$("#search_article_button").trigger("click");
			}
		});

	});
</script>